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

Configuration for the audio.com. More...

#include <ServiceConfig.h>

Collaboration diagram for audacity::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 (bool preferLossless=true) 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...
 
std::string GetCreateProjectUrl () const
 
std::string GetCreateSnapshotUrl (std::string_view projectId) const
 
std::string GetSnapshotSyncUrl (std::string_view projectId, std::string_view snapshotId) const
 
std::string GetProjectsUrl (int page, int pageSize, std::string_view searchTerm) const
 
std::string GetProjectInfoUrl (std::string_view projectId) const
 
std::string GetSnapshotInfoUrl (std::string_view projectId, std::string_view snapshotId) const
 
std::string GetDeleteSnapshotUrl (std::string_view projectId, std::string_view snapshotId) const
 
std::string GetNetworkStatsUrl (std::string_view projectId) const
 
std::string GetProjectPageUrl (std::string_view userId, std::string_view projectId) const
 
std::string GetProjectsPageUrl (std::string_view userId) const
 

Private Attributes

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

Detailed Description

Configuration for the audio.com.

Definition at line 22 of file ServiceConfig.h.

Constructor & Destructor Documentation

◆ ServiceConfig()

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

Definition at line 85 of file ServiceConfig.cpp.

86{
95}
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 audacity::cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComApiEndpoint, audacity::cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComAudioDownloadMimeType, audacity::cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComFinishUploadPage, audacity::cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComFrontendUrl, audacity::cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComOAuthClientID, audacity::cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComOAuthClientSecret, audacity::cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComOAuthLoginPage, audacity::cloud::audiocom::anonymous_namespace{ServiceConfig.cpp}::audioComOAuthRedirectURL, mApiEndpoint, mFinishUploadPage, mFrontendURL, 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 audacity::cloud::audiocom::ServiceConfig::GetAcceptLanguageValue ( ) const

Returns the preferred language.

Definition at line 203 of file ServiceConfig.cpp.

204{
205 auto language = Languages::GetLang();
206
207 if (language.Contains(L"-") && language.Length() > 2)
208 return wxString::Format(
209 "%s;q=1.0, %s;q=0.7, *;q=0.5", language, language.Left(2))
210 .ToStdString();
211 else
212 return wxString::Format("%s;q=1.0, *;q=0.5", language).ToStdString();
213}
wxString GetLang()
Definition: Languages.cpp:395

References Languages::GetLang().

Referenced by audacity::cloud::audiocom::SetCommonHeaders(), audacity::cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::SetRequiredHeaders(), and audacity::cloud::audiocom::sync::LocalProjectSnapshot::UpdateProjectSnapshot().

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

◆ GetAPIEndpoint()

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

API endpoint.

Definition at line 97 of file ServiceConfig.cpp.

98{
99 return mApiEndpoint;
100}

References mApiEndpoint.

◆ GetAPIUrl()

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

Helper to construct the full URLs for the API.

Definition at line 123 of file ServiceConfig.cpp.

124{
125 return mApiEndpoint + std::string(apiURI);
126}

References mApiEndpoint.

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

Here is the caller graph for this function:

◆ GetAudioURL()

std::string audacity::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 137 of file ServiceConfig.cpp.

139{
140 return Substitute(
141 "{frontend_url}/{user_slug}/audio/{audio_slug}/edit",
142 { { "frontend_url", mFrontendURL },
143 { "user_slug", userSlug },
144 { "audio_slug", audioSlug } });
145}
std::string Substitute(std::string pattern, std::initializer_list< std::pair< std::string_view, std::string_view > > substitutions)

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

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

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

◆ GetCreateProjectUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetCreateProjectUrl ( ) const

Definition at line 215 of file ServiceConfig.cpp.

216{
217 return GetAPIUrl("/project");
218}
std::string GetAPIUrl(std::string_view apiURI) const
Helper to construct the full URLs for the API.

References GetAPIUrl().

Referenced by audacity::cloud::audiocom::sync::LocalProjectSnapshot::UpdateProjectSnapshot().

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

◆ GetCreateSnapshotUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetCreateSnapshotUrl ( std::string_view  projectId) const

Definition at line 221 of file ServiceConfig.cpp.

222{
223 return Substitute(
224 "{api_url}/project/{project_id}/snapshot",
225 { { "api_url", mApiEndpoint }, { "project_id", projectId } });
226}

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

Referenced by audacity::cloud::audiocom::sync::LocalProjectSnapshot::UpdateProjectSnapshot().

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

◆ GetDeleteSnapshotUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetDeleteSnapshotUrl ( std::string_view  projectId,
std::string_view  snapshotId 
) const

Definition at line 277 of file ServiceConfig.cpp.

279{
280 return Substitute(
281 "{api_url}/project/{project_id}/snapshot/{snapshot_id}",
282 {
283 { "api_url", mApiEndpoint },
284 { "project_id", projectId },
285 { "snapshot_id", snapshotId },
286 });
287}

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

Referenced by audacity::cloud::audiocom::sync::LocalProjectSnapshot::DeleteSnapshot().

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

◆ GetDownloadMime()

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

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

Definition at line 198 of file ServiceConfig.cpp.

199{
200 return mPreferredMimeType;
201}

References mPreferredMimeType.

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

Here is the caller graph for this function:

◆ GetExportConfig()

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

Export configuration suitable for the mime type provided.

Definition at line 162 of file ServiceConfig.cpp.

163{
164 if (mimeType == "audio/x-wavpack")
165 {
166 rapidjson::Document config;
167 config.SetObject();
168 config.AddMember("quality", rapidjson::Value(2), config.GetAllocator());
169 config.AddMember("bit_rate", rapidjson::Value(40), config.GetAllocator());
170 config.AddMember("bit_depth", 24, config.GetAllocator());
171 config.AddMember("hybrid_mode", false, config.GetAllocator());
172 return config;
173 }
174 else if (mimeType == "audio/x-flac")
175 {
176 rapidjson::Document config;
177 config.SetObject();
178 config.AddMember(
179 "bit_depth", rapidjson::Value(24), config.GetAllocator());
180 config.AddMember("level", rapidjson::Value(5), config.GetAllocator());
181 }
182 else if (mimeType == "audio/x-wav")
183 {
184 return {};
185 }
186 else if (mimeType == "audio/mpeg")
187 {
188 rapidjson::Document config;
189 config.SetObject();
190 config.AddMember("mode", rapidjson::Value("VBR"), config.GetAllocator());
191 config.AddMember("quality", rapidjson::Value(5), config.GetAllocator());
192 return config;
193 }
194
195 throw std::invalid_argument("unknown mime-type");
196}

Referenced by audacity::cloud::audiocom::sync::MixdownUploader::ExportProject(), and audacity::cloud::audiocom::ShareAudioDialog::ExportProject().

Here is the caller graph for this function:

◆ GetFinishUploadPage()

std::string audacity::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 128 of file ServiceConfig.cpp.

130{
131 return Substitute(
132 mFinishUploadPage, { { "audio_id", audioID },
133 { "auth_token", token },
134 { "auth_client_id", mOAuthClientID } });
135}

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

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

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

◆ GetNetworkStatsUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetNetworkStatsUrl ( std::string_view  projectId) const

Definition at line 289 of file ServiceConfig.cpp.

290{
291 return Substitute(
292 "{api_url}/project/{project_id}/network-stats",
293 {
294 { "api_url", mApiEndpoint },
295 { "project_id", projectId },
296 });
297}

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

Here is the call graph for this function:

◆ GetOAuthClientID()

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

OAuth2 client ID.

Definition at line 108 of file ServiceConfig.cpp.

109{
110 return mOAuthClientID;
111}

References mOAuthClientID.

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

Here is the caller graph for this function:

◆ GetOAuthClientSecret()

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

OAuth2 client secret.

Definition at line 113 of file ServiceConfig.cpp.

114{
115 return mOAuthClientSecret;
116}

References mOAuthClientSecret.

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

Here is the caller graph for this function:

◆ GetOAuthLoginPage()

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

Page to open in browser to initiate OAuth.

Definition at line 102 of file ServiceConfig.cpp.

103{
104 return Substitute(
105 mOAuthLoginPage, { { "auth_client_id", GetOAuthClientID() } });
106}
std::string GetOAuthClientID() const
OAuth2 client ID.

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

Here is the call graph for this function:

◆ GetOAuthRedirectURL()

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

OAuth2 redirect URL. Only used to satisfy the protocol.

Definition at line 118 of file ServiceConfig.cpp.

119{
120 return mOAuthRedirectURL;
121}

References mOAuthRedirectURL.

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

Here is the caller graph for this function:

◆ GetPreferredAudioFormats()

std::vector< std::string > audacity::cloud::audiocom::ServiceConfig::GetPreferredAudioFormats ( bool  preferLossless = true) const

Preferred audio format.

Definition at line 153 of file ServiceConfig.cpp.

154{
155 if (preferLossless)
156 return { "audio/x-wavpack", "audio/x-flac", "audio/x-wav" };
157 else
158 return { "audio/mpeg" };
159}

◆ GetProgressCallbackTimeout()

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

Timeout between progress callbacks.

Definition at line 147 of file ServiceConfig.cpp.

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

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

Here is the caller graph for this function:

◆ GetProjectInfoUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetProjectInfoUrl ( std::string_view  projectId) const

Definition at line 256 of file ServiceConfig.cpp.

257{
258 return Substitute(
259 "{api_url}/project/{project_id}", {
260 { "api_url", mApiEndpoint },
261 { "project_id", projectId },
262 });
263}

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

Referenced by audacity::cloud::audiocom::anonymous_namespace{CloudSyncService.cpp}::GetProjectInfo().

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

◆ GetProjectPageUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetProjectPageUrl ( std::string_view  userId,
std::string_view  projectId 
) const

Definition at line 299 of file ServiceConfig.cpp.

301{
302 return Substitute(
303 "{frontend_url}/{user_slug}/projects/{project_id}",
304 {
305 { "frontend_url", mFrontendURL },
306 { "user_slug", userId },
307 { "project_id", projectId },
308 });
309}

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

Referenced by audacity::cloud::audiocom::sync::ProjectCloudExtension::GetCloudProjectPage(), and audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetSelectedProjectUrl().

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

◆ GetProjectsPageUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetProjectsPageUrl ( std::string_view  userId) const

Definition at line 311 of file ServiceConfig.cpp.

312{
313 return Substitute(
314 "{frontend_url}/{user_slug}/projects",
315 {
316 { "frontend_url", mFrontendURL },
317 { "user_slug", userId },
318 });
319}

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

Here is the call graph for this function:

◆ GetProjectsUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetProjectsUrl ( int  page,
int  pageSize,
std::string_view  searchTerm 
) const

Definition at line 238 of file ServiceConfig.cpp.

240{
241 if (searchTerm.empty())
242 return Substitute(
243 "{api_url}/project?page={page}&per-page={page_size}",
244 { { "api_url", mApiEndpoint },
245 { "page", std::to_string(page) },
246 { "page_size", std::to_string(pageSize) }, });
247
248 return Substitute(
249 "{api_url}/project?page={page}&per-page={page_size}&q={search_term}",
250 { { "api_url", mApiEndpoint },
251 { "page", std::to_string(page) },
252 { "page_size", std::to_string(pageSize) },
253 { "search_term", searchTerm }, });
254}

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

Here is the call graph for this function:

◆ GetSnapshotInfoUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetSnapshotInfoUrl ( std::string_view  projectId,
std::string_view  snapshotId 
) const

Definition at line 265 of file ServiceConfig.cpp.

267{
268 return Substitute(
269 "{api_url}/project/{project_id}/snapshot/{snapshot_id}?expand=blocks,file_url",
270 {
271 { "api_url", mApiEndpoint },
272 { "project_id", projectId },
273 { "snapshot_id", snapshotId },
274 });
275}

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

Referenced by audacity::cloud::audiocom::anonymous_namespace{CloudSyncService.cpp}::GetSnapshotInfo().

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

◆ GetSnapshotSyncUrl()

std::string audacity::cloud::audiocom::ServiceConfig::GetSnapshotSyncUrl ( std::string_view  projectId,
std::string_view  snapshotId 
) const

Definition at line 228 of file ServiceConfig.cpp.

230{
231 return Substitute(
232 "{api_url}/project/{project_id}/snapshot/{snapshot_id}/sync",
233 { { "api_url", mApiEndpoint },
234 { "project_id", projectId },
235 { "snapshot_id", snapshotId } });
236}

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

Referenced by audacity::cloud::audiocom::sync::LocalProjectSnapshot::MarkSnapshotSynced(), audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::ResumedSnaphotUploadOperation::RefreshUrls(), and audacity::cloud::audiocom::sync::LocalProjectSnapshot::StorePendingSnapshot().

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

Member Data Documentation

◆ mApiEndpoint

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

◆ mFinishUploadPage

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

Definition at line 78 of file ServiceConfig.h.

Referenced by GetFinishUploadPage(), and ServiceConfig().

◆ mFrontendURL

std::string audacity::cloud::audiocom::ServiceConfig::mFrontendURL
private

Definition at line 79 of file ServiceConfig.h.

Referenced by GetAudioURL(), GetProjectPageUrl(), GetProjectsPageUrl(), and ServiceConfig().

◆ mOAuthClientID

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

Definition at line 74 of file ServiceConfig.h.

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

◆ mOAuthClientSecret

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

Definition at line 75 of file ServiceConfig.h.

Referenced by GetOAuthClientSecret(), and ServiceConfig().

◆ mOAuthLoginPage

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

Definition at line 77 of file ServiceConfig.h.

Referenced by GetOAuthLoginPage(), and ServiceConfig().

◆ mOAuthRedirectURL

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

Definition at line 76 of file ServiceConfig.h.

Referenced by GetOAuthRedirectURL(), and ServiceConfig().

◆ mPreferredMimeType

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

Definition at line 80 of file ServiceConfig.h.

Referenced by GetDownloadMime(), and ServiceConfig().


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