Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
cloud::audiocom::ServiceConfig Class Referencefinal

Configuration for the audio.com. More...

#include <ServiceConfig.h>

Collaboration diagram for cloud::audiocom::ServiceConfig:
[legend]

Public Member Functions

 ServiceConfig ()
 
std::string GetAPIEndpoint () const
 API endpoint. More...
 
std::string GetOAuthLoginPage () const
 Page to open in browser to initiate OAuth. More...
 
std::string GetOAuthClientID () const
 OAuth2 client ID. More...
 
std::string GetOAuthClientSecret () const
 OAuth2 client secret. More...
 
std::string GetOAuthRedirectURL () const
 OAuth2 redirect URL. Only used to satisfy the protocol. More...
 
std::string GetAPIUrl (std::string_view apiURI) const
 Helper to construct the full URLs for the API. More...
 
std::string GetFinishUploadPage (std::string_view audioID, std::string_view token) const
 Helper to construct the page URL for the anonymous upload last stage. More...
 
std::string GetAudioURL (std::string_view userSlug, std::string_view audioSlug) const
 Helper to construct the page URL for the authorised upload. More...
 
std::chrono::milliseconds GetProgressCallbackTimeout () const
 Timeout between progress callbacks. More...
 
std::vector< std::string > GetPreferredAudioFormats () const
 Preferred audio format. More...
 
rapidjson::Document GetExportConfig (const std::string &exporterName) const
 Export configuration suitable for the mime type provided. More...
 
std::string GetDownloadMime () const
 
std::string GetAcceptLanguageValue () const
 Returns the preferred language. More...
 

Private Attributes

std::string mApiEndpoint
 
std::string mOAuthClientID
 
std::string mOAuthClientSecret
 
std::string mOAuthRedirectURL
 
std::string mOAuthLoginPage
 
std::string mFinishUploadPage
 
std::string mAudioURL
 
std::string mPreferredMimeType
 

Detailed Description

Configuration for the audio.com.

Definition at line 22 of file ServiceConfig.h.

Constructor & Destructor Documentation

◆ ServiceConfig()

cloud::audiocom::ServiceConfig::ServiceConfig ( )

Definition at line 89 of file ServiceConfig.cpp.

90{
99}
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
std::string ToUTF8(const std::wstring &wstr)

References cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComApiEndpoint, cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComAudioDownloadMimeType, cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComAudioURL, cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComFinishUploadPage, cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComOAuthClientID, cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComOAuthClientSecret, cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComOAuthLoginPage, cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComOAuthRedirectURL, mApiEndpoint, mAudioURL, mFinishUploadPage, mOAuthClientID, mOAuthClientSecret, mOAuthLoginPage, mOAuthRedirectURL, mPreferredMimeType, Setting< T >::Read(), and audacity::ToUTF8().

Here is the call graph for this function:

Member Function Documentation

◆ GetAcceptLanguageValue()

std::string cloud::audiocom::ServiceConfig::GetAcceptLanguageValue ( ) const

Returns the preferred language.

Definition at line 190 of file ServiceConfig.cpp.

191{
192 auto language = Languages::GetLang();
193
194 if (language.Contains(L"-") && language.Length() > 2)
195 return wxString::Format("%s;q=1.0, %s;q=0.7, *;q=0.5", language, language.Left(2)).ToStdString();
196 else
197 return wxString::Format("%s;q=1.0, *;q=0.5", language).ToStdString();
198}
wxString GetLang()
Definition: Languages.cpp:395

References Languages::GetLang().

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::SetRequiredHeaders().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAPIEndpoint()

std::string cloud::audiocom::ServiceConfig::GetAPIEndpoint ( ) const

API endpoint.

Definition at line 101 of file ServiceConfig.cpp.

102{
103 return mApiEndpoint;
104}

References mApiEndpoint.

◆ GetAPIUrl()

std::string cloud::audiocom::ServiceConfig::GetAPIUrl ( std::string_view  apiURI) const

Helper to construct the full URLs for the API.

Definition at line 127 of file ServiceConfig.cpp.

128{
129 return mApiEndpoint + std::string(apiURI);
130}

References mApiEndpoint.

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::DiscardResult(), cloud::audiocom::OAuthService::DoAuthorise(), and cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::InitiateUpload().

Here is the caller graph for this function:

◆ GetAudioURL()

std::string cloud::audiocom::ServiceConfig::GetAudioURL ( std::string_view  userSlug,
std::string_view  audioSlug 
) const

Helper to construct the page URL for the authorised upload.

Definition at line 141 of file ServiceConfig.cpp.

143{
144 return Substitute(
145 mAudioURL, { { "user_slug", userSlug }, { "audio_slug", audioSlug } });
146}
std::string Substitute(std::string pattern, std::initializer_list< std::pair< std::string_view, std::string_view > > substitutions)

References mAudioURL, and cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::Substitute().

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::CompletePromise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDownloadMime()

std::string cloud::audiocom::ServiceConfig::GetDownloadMime ( ) const

Return the mime type server should store the file. This is a requirement from audiocom

Definition at line 185 of file ServiceConfig.cpp.

186{
187 return mPreferredMimeType;
188}

References mPreferredMimeType.

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::GetUploadRequestPayload().

Here is the caller graph for this function:

◆ GetExportConfig()

rapidjson::Document cloud::audiocom::ServiceConfig::GetExportConfig ( const std::string &  exporterName) const

Export configuration suitable for the mime type provided.

Definition at line 158 of file ServiceConfig.cpp.

159{
160 if(mimeType == "audio/x-wavpack")
161 {
162 rapidjson::Document config;
163 config.SetObject();
164 config.AddMember("quality", rapidjson::Value(2), config.GetAllocator());
165 config.AddMember("bit_rate", rapidjson::Value(40), config.GetAllocator());
166 config.AddMember("bit_depth", 24, config.GetAllocator());
167 config.AddMember("hybrid_mode", false, config.GetAllocator());
168 return config;
169 }
170 if(mimeType == "audio/x-flac")
171 {
172 rapidjson::Document config;
173 config.SetObject();
174 config.AddMember("bit_depth", rapidjson::Value(24), config.GetAllocator());
175 config.AddMember("level", rapidjson::Value(5), config.GetAllocator());
176 }
177 if(mimeType == "audio/x-wav")
178 {
179 return {};
180 }
181 throw std::invalid_argument("unknown mime-type");
182}

Referenced by cloud::audiocom::ShareAudioDialog::ExportProject().

Here is the caller graph for this function:

◆ GetFinishUploadPage()

std::string cloud::audiocom::ServiceConfig::GetFinishUploadPage ( std::string_view  audioID,
std::string_view  token 
) const

Helper to construct the page URL for the anonymous upload last stage.

Definition at line 132 of file ServiceConfig.cpp.

134{
135 return Substitute(
136 mFinishUploadPage, { { "audio_id", audioID },
137 { "auth_token", token },
138 { "auth_client_id", mOAuthClientID } });
139}

References mFinishUploadPage, mOAuthClientID, and cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::Substitute().

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::CompletePromise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetOAuthClientID()

std::string cloud::audiocom::ServiceConfig::GetOAuthClientID ( ) const

OAuth2 client ID.

Definition at line 112 of file ServiceConfig.cpp.

113{
114 return mOAuthClientID;
115}

References mOAuthClientID.

Referenced by GetOAuthLoginPage(), and cloud::audiocom::anonymous_namespace{OAuthService.cpp}::WriteCommonFields().

Here is the caller graph for this function:

◆ GetOAuthClientSecret()

std::string cloud::audiocom::ServiceConfig::GetOAuthClientSecret ( ) const

OAuth2 client secret.

Definition at line 117 of file ServiceConfig.cpp.

118{
119 return mOAuthClientSecret;
120}

References mOAuthClientSecret.

Referenced by cloud::audiocom::anonymous_namespace{OAuthService.cpp}::WriteCommonFields().

Here is the caller graph for this function:

◆ GetOAuthLoginPage()

std::string cloud::audiocom::ServiceConfig::GetOAuthLoginPage ( ) const

Page to open in browser to initiate OAuth.

Definition at line 106 of file ServiceConfig.cpp.

107{
108 return Substitute(
109 mOAuthLoginPage, { { "auth_client_id", GetOAuthClientID() } });
110}
std::string GetOAuthClientID() const
OAuth2 client ID.

References GetOAuthClientID(), mOAuthLoginPage, and cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::Substitute().

Here is the call graph for this function:

◆ GetOAuthRedirectURL()

std::string cloud::audiocom::ServiceConfig::GetOAuthRedirectURL ( ) const

OAuth2 redirect URL. Only used to satisfy the protocol.

Definition at line 122 of file ServiceConfig.cpp.

123{
124 return mOAuthRedirectURL;
125}

References mOAuthRedirectURL.

Referenced by cloud::audiocom::OAuthService::AuthoriseCode().

Here is the caller graph for this function:

◆ GetPreferredAudioFormats()

std::vector< std::string > cloud::audiocom::ServiceConfig::GetPreferredAudioFormats ( ) const

Preferred audio format.

Definition at line 153 of file ServiceConfig.cpp.

154{
155 return { "audio/x-wavpack", "audio/x-flac", "audio/x-wav" };
156}

◆ GetProgressCallbackTimeout()

std::chrono::milliseconds cloud::audiocom::ServiceConfig::GetProgressCallbackTimeout ( ) const

Timeout between progress callbacks.

Definition at line 148 of file ServiceConfig.cpp.

149{
150 return std::chrono::seconds(3);
151}

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::HandleUploadProgress().

Here is the caller graph for this function:

Member Data Documentation

◆ mApiEndpoint

std::string cloud::audiocom::ServiceConfig::mApiEndpoint
private

Definition at line 55 of file ServiceConfig.h.

Referenced by GetAPIEndpoint(), GetAPIUrl(), and ServiceConfig().

◆ mAudioURL

std::string cloud::audiocom::ServiceConfig::mAudioURL
private

Definition at line 61 of file ServiceConfig.h.

Referenced by GetAudioURL(), and ServiceConfig().

◆ mFinishUploadPage

std::string cloud::audiocom::ServiceConfig::mFinishUploadPage
private

Definition at line 60 of file ServiceConfig.h.

Referenced by GetFinishUploadPage(), and ServiceConfig().

◆ mOAuthClientID

std::string cloud::audiocom::ServiceConfig::mOAuthClientID
private

Definition at line 56 of file ServiceConfig.h.

Referenced by GetFinishUploadPage(), GetOAuthClientID(), and ServiceConfig().

◆ mOAuthClientSecret

std::string cloud::audiocom::ServiceConfig::mOAuthClientSecret
private

Definition at line 57 of file ServiceConfig.h.

Referenced by GetOAuthClientSecret(), and ServiceConfig().

◆ mOAuthLoginPage

std::string cloud::audiocom::ServiceConfig::mOAuthLoginPage
private

Definition at line 59 of file ServiceConfig.h.

Referenced by GetOAuthLoginPage(), and ServiceConfig().

◆ mOAuthRedirectURL

std::string cloud::audiocom::ServiceConfig::mOAuthRedirectURL
private

Definition at line 58 of file ServiceConfig.h.

Referenced by GetOAuthRedirectURL(), and ServiceConfig().

◆ mPreferredMimeType

std::string cloud::audiocom::ServiceConfig::mPreferredMimeType
private

Definition at line 62 of file ServiceConfig.h.

Referenced by GetDownloadMime(), and ServiceConfig().


The documentation for this class was generated from the following files: