Audacity 3.2.0
Namespaces | Classes | Enumerations | Functions | Variables
audacity::cloud::audiocom Namespace Reference

Namespaces

namespace  anonymous_namespace{AuthorizationHandler.cpp}
 
namespace  anonymous_namespace{CloudSyncService.cpp}
 
namespace  anonymous_namespace{NetworkUtils.cpp}
 
namespace  anonymous_namespace{OAuthService.cpp}
 
namespace  anonymous_namespace{ServiceConfig.cpp}
 
namespace  anonymous_namespace{ShareAudioDialog.cpp}
 
namespace  anonymous_namespace{UploadService.cpp}
 
namespace  anonymous_namespace{UserPanel.cpp}
 
namespace  anonymous_namespace{UserService.cpp}
 
namespace  sync
 

Classes

class  AuthorizationHandler
 
struct  AuthResult
 
struct  AuthStateChangedMessage
 Message that is sent when authorization state changes. More...
 
class  CloudSyncService
 
class  LinkFailedDialog
 
class  LinkSucceededDialog
 
class  LinkWithTokenDialog
 
class  OAuthService
 Service responsible for OAuth authentication against the audio.com service. More...
 
struct  ResponseResult
 
class  ServiceConfig
 Configuration for the audio.com. More...
 
class  ShareAudioDialog
 
struct  TransferStats
 
struct  UploadFailedPayload
 This structure represents an upload error as returned by the server. More...
 
class  UploadOperation
 Class used to track the upload operation. More...
 
struct  UploadOperationCompleted
 
class  UploadOperationHandle
 A unique_ptr like class that holds a pointer to UploadOperation. More...
 
class  UploadService
 Service, responsible for uploading audio files to audio.com. More...
 
struct  UploadSuccessfulPayload
 This structure represents the payload associated with successful upload. More...
 
struct  UserDataChanged
 
class  UserImage
 
class  UserPanel
 
struct  UserPanelStateChangedMessage
 
class  UserService
 Service for providing information about the user profile. More...
 

Enumerations

enum class  SyncResultCode {
  Success , Cancelled , Expired , Conflict ,
  ConnectionFailed , PaymentRequired , TooLarge , Unauthorized ,
  Forbidden , NotFound , UnexpectedResponse , InternalClientError ,
  InternalServerError , SyncImpossible , UnknownError
}
 

Functions

ResponseResult GetResponseResult (IResponse &response, bool readBody)
 
void SetCommonHeaders (Request &request)
 
bool IsUploadRecoverable (SyncResultCode code)
 
OAuthServiceGetOAuthService ()
 Returns the instance of the OAuthService. More...
 
const ServiceConfigGetServiceConfig ()
 Returns the instance of the ServiceConfig. More...
 
wxString GetUploadTempPath ()
 
UserServiceGetUserService ()
 
AuthorizationHandlerGetAuthorizationHandler ()
 
AuthResult PerformBlockingAuth (AudacityProject *project, AudiocomTrace trace, const TranslatableString &alternativeActionLabel)
 

Variables

StringSetting CloudProjectsSavePath
 
IntSetting DaysToKeepFiles
 

Detailed Description


Audacity: A Digital Audio Editor

CloudLibrarySettings.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

CloudLibrarySettings.h

Dmitry Vedenko


Audacity: A Digital Audio Editor

CloudSyncService.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

NetworkUtils.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

OAuthService.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

ServiceConfig.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

DataUploader.h

Dmitry Vedenko


Audacity: A Digital Audio Editor

UploadService.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

UserService.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

UserService.h

Dmitry Vedenko


Audacity: A Digital Audio Editor

AuthorizationHandler.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

LinkFailedDialog.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

LinkSucceededDialog.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

LinkSucceededDialog.h

Dmitry Vedenko


Audacity: A Digital Audio Editor

LinkAccountDialog.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

ShareAudioDialog.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

UserImage.cpp

Dmitry Vedenko


Audacity: A Digital Audio Editor

UserImage.h

Dmitry Vedenko


Audacity: A Digital Audio Editor

UserPanel.cpp

Dmitry Vedenko

Enumeration Type Documentation

◆ SyncResultCode

Enumerator
Success 
Cancelled 
Expired 
Conflict 
ConnectionFailed 
PaymentRequired 
TooLarge 
Unauthorized 
Forbidden 
NotFound 
UnexpectedResponse 
InternalClientError 
InternalServerError 
SyncImpossible 
UnknownError 

Definition at line 42 of file NetworkUtils.h.

Function Documentation

◆ GetAuthorizationHandler()

AuthorizationHandler & audacity::cloud::audiocom::GetAuthorizationHandler ( )

◆ GetOAuthService()

CLOUD_AUDIOCOM_API OAuthService & audacity::cloud::audiocom::GetOAuthService ( )

Returns the instance of the OAuthService.

Definition at line 569 of file OAuthService.cpp.

570{
571 static OAuthService service;
572 return service;
573}
Service responsible for OAuth authentication against the audio.com service.
Definition: OAuthService.h:43

Referenced by LoginDialog::ContinueCreateAccount(), LoginDialog::ContinueSignIn(), audacity::cloud::audiocom::sync::ProjectCloudExtension::GetCloudProjectPage(), audacity::cloud::audiocom::CloudSyncService::GetHeadSnapshotID(), audacity::cloud::audiocom::CloudSyncService::GetProjects(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetSelectedProjectUrl(), LoginDialog::LoginDialog(), audacity::cloud::audiocom::sync::ProjectCloudUIExtension::OnCloudStatusChanged(), audacity::cloud::audiocom::LinkWithTokenDialog::OnContinue(), audacity::cloud::audiocom::UserPanel::OnLinkButtonPressed(), anonymous_namespace{CloudProjectFileIOExtensions.cpp}::IOExtension::OnSave(), audacity::cloud::audiocom::anonymous_namespace{OAuthService.cpp}::OAuthServiceSettingsResetHandler::OnSettingResetEnd(), audacity::cloud::audiocom::CloudSyncService::OpenFromCloud(), PerformBlockingAuth(), anonymous_namespace{CloudProjectFileIOExtensions.cpp}::IOExtension::PerformCloudSave(), audacity::cloud::audiocom::ShareAudioDialog::InitialStatePanel::PopulateInitialStatePanel(), anonymous_namespace{AudioComPrefsPanel.cpp}::AudioComPrefsPanel::PopulateOrExchange(), SetCommonHeaders(), audacity::cloud::audiocom::sync::CloudProjectPropertiesDialog::SetupEvents(), audacity::cloud::audiocom::CloudSyncService::SyncProject(), audacity::cloud::audiocom::UserService::UpdateUserData(), audacity::cloud::audiocom::UserPanel::UpdateUserData(), and audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::WaitForAuth().

Here is the caller graph for this function:

◆ GetResponseResult()

ResponseResult audacity::cloud::audiocom::GetResponseResult ( IResponse response,
bool  readBody 
)

Definition at line 86 of file NetworkUtils.cpp.

87{
88 const auto resultCode = GuessResultCode(response);
89
90 if (resultCode == SyncResultCode::Success)
91 return { resultCode,
92 readBody ? response.readAll<std::string>() : std::string {} };
93
94 if (response.getError() != NetworkError::HTTPError)
95 return { resultCode, response.getErrorString() };
96
97 return { resultCode,
98 std::string("HTTP ") + std::to_string(response.getHTTPCode()) +
99 std::string("\n") + response.readAll<std::string>() };
100}
virtual std::string getErrorString() const =0
virtual unsigned getHTTPCode() const noexcept=0
virtual NetworkError getError() const noexcept=0
SyncResultCode GuessResultCode(IResponse &response) noexcept

References audacity::network_manager::IResponse::getError(), audacity::network_manager::IResponse::getErrorString(), audacity::network_manager::IResponse::getHTTPCode(), audacity::cloud::audiocom::anonymous_namespace{NetworkUtils.cpp}::GuessResultCode(), audacity::network_manager::IResponse::readAll(), and Success.

Referenced by audacity::cloud::audiocom::sync::DataUploader::UploadOperation::ConfirmUpload(), audacity::cloud::audiocom::sync::RemoteProjectSnapshot::DownloadBlob(), audacity::cloud::audiocom::sync::DataUploader::UploadOperation::FailUpload(), audacity::cloud::audiocom::CloudSyncService::GetProjects(), audacity::cloud::audiocom::anonymous_namespace{CloudSyncService.cpp}::PerformProjectGetRequest(), and audacity::cloud::audiocom::sync::DataUploader::UploadOperation::PerformUpload().

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

◆ GetServiceConfig()

CLOUD_AUDIOCOM_API const ServiceConfig & audacity::cloud::audiocom::GetServiceConfig ( )

Returns the instance of the ServiceConfig.

Definition at line 382 of file ServiceConfig.cpp.

383{
384 static ServiceConfig config;
385 return config;
386}
Configuration for the audio.com.
Definition: ServiceConfig.h:25

Referenced by audacity::cloud::audiocom::OAuthService::Authorize(), audacity::cloud::audiocom::sync::MixdownUploader::ExportProject(), audacity::cloud::audiocom::ShareAudioDialog::ExportProject(), audacity::cloud::audiocom::sync::ProjectCloudExtension::GetCloudProjectPage(), audacity::cloud::audiocom::CloudSyncService::GetHeadSnapshotID(), audacity::cloud::audiocom::CloudSyncService::GetProjects(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::GetSelectedProjectUrl(), audacity::cloud::audiocom::anonymous_namespace{UploadService.cpp}::GetUploadRequestPayload(), audacity::cloud::audiocom::OAuthService::HandleLinkURI(), audacity::cloud::audiocom::OAuthService::MakeAudioComAuthorizeURL(), audacity::cloud::audiocom::OAuthService::MakeOAuthRequestURL(), audacity::cloud::audiocom::sync::ProjectCloudUIExtension::OnCloudStatusChanged(), anonymous_namespace{CloudProjectFileIOExtensions.cpp}::IOExtension::OnSave(), audacity::cloud::audiocom::CloudSyncService::OpenFromCloud(), anonymous_namespace{CloudProjectFileIOExtensions.cpp}::IOExtension::PerformCloudSave(), audacity::cloud::audiocom::ShareAudioDialog::InitialStatePanel::PopulateInitialStatePanel(), anonymous_namespace{AudioComPrefsPanel.cpp}::AudioComPrefsPanel::PopulateOrExchange(), audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::ResumedSnaphotUploadOperation::RefreshUrls(), audacity::cloud::audiocom::OAuthService::Register(), audacity::cloud::audiocom::CloudSyncService::ReportUploadStats(), SetCommonHeaders(), audacity::cloud::audiocom::CloudSyncService::SyncProject(), audacity::cloud::audiocom::UserService::UpdateUserData(), audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::ResumedSnaphotUploadOperation::UploadBlocks(), audacity::cloud::audiocom::sync::UploadMixdown(), audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::ResumedSnaphotUploadOperation::UploadSnapshot(), audacity::cloud::audiocom::OAuthService::ValidateAuth(), and audacity::cloud::audiocom::anonymous_namespace{OAuthService.cpp}::WriteClientFields().

Here is the caller graph for this function:

◆ GetUploadTempPath()

CLOUD_AUDIOCOM_API wxString audacity::cloud::audiocom::GetUploadTempPath ( )

Definition at line 628 of file UploadService.cpp.

629{
630 const auto tempPath = TempDirectory::DefaultTempDir();
631
632 if (!wxDirExists(tempPath))
633 {
634 // Temp directory was not created yet.
635 // Is it a first run of Audacity?
636 // In any case, let's wait for some better time
637 return {};
638 }
639
641 tempPath, XO("Cannot proceed to upload.")))
642 return {};
643
644 return tempPath + "/cloud/";
645}
XO("Cut/Copy/Paste")
FILES_API bool WritableLocationCheck(const FilePath &path, const TranslatableString &message)
Check location on writable access and return true if checked successfully.
FILES_API const FilePath & DefaultTempDir()

References TempDirectory::DefaultTempDir(), FileNames::WritableLocationCheck(), and XO().

Referenced by audacity::cloud::audiocom::sync::anonymous_namespace{MixdownUploader.cpp}::GenerateTempPath(), and audacity::cloud::audiocom::anonymous_namespace{ShareAudioDialog.cpp}::GenerateTempPath().

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

◆ GetUserService()

CLOUD_AUDIOCOM_API UserService & audacity::cloud::audiocom::GetUserService ( )

◆ IsUploadRecoverable()

bool audacity::cloud::audiocom::IsUploadRecoverable ( SyncResultCode  code)

Definition at line 117 of file NetworkUtils.cpp.

118{
119 return code == SyncResultCode::Cancelled ||
120 code == SyncResultCode::ConnectionFailed ||
124 code == SyncResultCode::InternalClientError ||
126}

References Cancelled, ConnectionFailed, Forbidden, InternalClientError, InternalServerError, PaymentRequired, and Unauthorized.

Referenced by audacity::cloud::audiocom::sync::LocalProjectSnapshot::OnSnapshotCreated(), and audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::ResumedSnaphotUploadOperation::UploadSnapshot().

Here is the caller graph for this function:

◆ PerformBlockingAuth()

AuthResult audacity::cloud::audiocom::PerformBlockingAuth ( AudacityProject project,
AudiocomTrace  trace,
const TranslatableString alternativeActionLabel 
)

Definition at line 79 of file AuthorizationHandler.cpp.

82{
83 using namespace sync;
84 auto& oauthService = GetOAuthService();
85
86 // Assume, that the token is valid
87 // Services will need to handle 403 errors and refresh the token
88 if (GetOAuthService().HasAccessToken())
89 return { AuthResult::Status::Authorised, {} };
90
92 auto popSuppress =
94
95 if (oauthService.HasRefreshToken())
96 {
97 std::promise<std::optional<AuthResult>> promise;
98
99 oauthService.ValidateAuth(
100 [&promise](auto...) { promise.set_value({}); }, trace, true);
101
102 if (auto waitResult = WaitForAuth(promise.get_future(), project))
103 return *waitResult;
104 }
105
106 auto linkResult =
107 sync::LinkAccountDialog { project, alternativeActionLabel }.ShowDialog();
108
109 if (linkResult == LinkAccountDialog::CancelButtonIdentifier())
110 return { AuthResult::Status::Cancelled, {} };
111
112 if (linkResult == LinkAccountDialog::AlternativeButtonIdentifier())
113 return { AuthResult::Status::UseAlternative, {} };
114
115 std::promise<std::optional<AuthResult>> promise;
116
117 auto authSubscription = oauthService.Subscribe(
118 [&promise](auto& result)
119 {
120 promise.set_value(
121 result.authorised ?
122 AuthResult { AuthResult::Status::Authorised, {} } :
123 AuthResult { AuthResult::Status::Failure,
124 std::string(result.errorMessage) });
125 });
126
128
129 auto waitResult = WaitForAuth(promise.get_future(), project);
130
131 if (waitResult)
132 return *waitResult;
133
134 return AuthResult { AuthResult::Status::Failure, {} };
135}
const auto project
static bool SignIn(wxWindow *parent, Mode mode=Mode::SignIn)
std::optional< AuthResult > WaitForAuth(std::future< std::optional< AuthResult > > future, const AudacityProject *project)
AuthorizationHandler & GetAuthorizationHandler()
OAuthService & GetOAuthService()
Returns the instance of the OAuthService.

References audacity::cloud::audiocom::AuthResult::Authorised, audacity::cloud::audiocom::AuthResult::Cancelled, audacity::cloud::audiocom::AuthResult::Failure, GetAuthorizationHandler(), GetOAuthService(), audacity::cloud::audiocom::AuthorizationHandler::PopSuppressDialogs(), project, audacity::cloud::audiocom::AuthorizationHandler::PushSuppressDialogs(), audacity::cloud::audiocom::AuthResult::UseAlternative, and audacity::cloud::audiocom::anonymous_namespace{AuthorizationHandler.cpp}::WaitForAuth().

Referenced by anonymous_namespace{CloudProjectFileIOExtensions.cpp}::IOExtension::OnLoad(), audacity::cloud::audiocom::sync::OpenProjectFromCloud(), audacity::cloud::audiocom::sync::ProjectsListDialog::ProjectsTableData::Refresh(), anonymous_namespace{CloudProjectFileIOExtensions.cpp}::IOExtension::SaveCloudProject(), and audacity::cloud::audiocom::sync::SyncCloudProject().

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

◆ SetCommonHeaders()

void audacity::cloud::audiocom::SetCommonHeaders ( Request request)

Definition at line 102 of file NetworkUtils.cpp.

103{
104 const auto language = GetServiceConfig().GetAcceptLanguageValue();
105
106 if (!language.empty())
107 request.setHeader(
109
110 auto& oauthService = GetOAuthService();
111
112 if (oauthService.HasAccessToken())
113 request.setHeader(
114 common_headers::Authorization, oauthService.GetAccessToken());
115}
std::string GetAcceptLanguageValue() const
Returns the preferred language.
Request & setHeader(const std::string &name, std::string value)
Definition: Request.cpp:46
const ServiceConfig & GetServiceConfig()
Returns the instance of the ServiceConfig.

References audacity::network_manager::common_headers::AcceptLanguage, audacity::network_manager::common_headers::Authorization, audacity::cloud::audiocom::ServiceConfig::GetAcceptLanguageValue(), GetOAuthService(), GetServiceConfig(), and audacity::network_manager::Request::setHeader().

Referenced by audacity::cloud::audiocom::sync::LocalProjectSnapshot::DeleteSnapshot(), audacity::cloud::audiocom::CloudSyncService::GetProjects(), audacity::cloud::audiocom::sync::LocalProjectSnapshot::MarkSnapshotSynced(), audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::ResumedSnaphotUploadOperation::MarkSnapshotSynced(), audacity::cloud::audiocom::anonymous_namespace{CloudSyncService.cpp}::PerformProjectGetRequest(), audacity::cloud::audiocom::sync::anonymous_namespace{ResumedSnaphotUploadOperation.cpp}::ResumedSnaphotUploadOperation::RefreshUrls(), and audacity::cloud::audiocom::CloudSyncService::ReportUploadStats().

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

Variable Documentation

◆ CloudProjectsSavePath

CLOUD_AUDIOCOM_API StringSetting audacity::cloud::audiocom::CloudProjectsSavePath

◆ DaysToKeepFiles

CLOUD_AUDIOCOM_API IntSetting audacity::cloud::audiocom::DaysToKeepFiles