42 {
return std::make_shared<ProjectCloudUIExtension>(
project); }
52 , mCloudStatusChangedSubscription {
59ProjectCloudUIExtension::~ProjectCloudUIExtension() =
default;
72void ProjectCloudUIExtension::SetUploadProgress(
double progress)
77bool ProjectCloudUIExtension::AllowClosing()
79 while (mInSync.load(std::memory_order_acquire) && !mClosingCancelled)
81 if (mProgressDialog ==
nullptr)
84 XO(
"Save to audio.com"),
85 XO(
"Project is syncing with audio.com. Do you want to stop the sync process?"),
89 const auto result = mProgressDialog->Poll(mProgress * 10000, 10000);
93 mClosingCancelled =
true;
94 mProgressDialog.reset();
103 bool closingCancelled = mClosingCancelled;
104 mClosingCancelled =
false;
106 mProgressDialog.reset();
108 return !mInSync.load(std::memory_order_acquire) || !closingCancelled;
111void ProjectCloudUIExtension::OnCloudStatusChanged(
117 mProgressDialog.reset();
119 SetUploadProgress(message.
Progress);
122 if (message.
Status == ProjectSyncStatus::Synced)
125 if (message.
Status != ProjectSyncStatus::Failed || !message.
Error)
128 const auto error = *message.
Error;
137 case CloudSyncError::ProjectLimitReached:
139 case CloudSyncError::ProjectStorageLimitReached:
143 if (result == ProjectLimitDialog::VisitAudioComIdentifier())
150 const auto projectsPath = serviceConfig.GetProjectsPagePath(slug, message.
audiocomTrace);
151 const auto url = oauthService.MakeAudioComAuthorizeURL(slug, projectsPath);
157 XO(
"Waiting for space to free up"),
158 XO(
"Once you have made storage space available on audio.com, click Retry."),
163 else if (result == ProjectLimitDialog::SaveLocallyButtonIdentifier())
170 case CloudSyncError::ProjectVersionConflict:
174 ProjectVersionConflictDialogMode::Save }
175 .
ShowDialog() == ProjectVersionConflictDialog::UseLocalIdentifier())
185 case CloudSyncError::ProjectNotFound:
189 NotCloudProjectDialog::SaveLocallyIdentifier())
200 case CloudSyncError::Network:
205 case CloudSyncError::DataUploadFailed:
207 case CloudSyncError::Server:
209 case CloudSyncError::ClientFailure:
Toolkit-neutral facade for basic user interface services.
Declare functions to perform UTF-8 to std::wstring conversions.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
typename GlobalVariable< OnCloseHook, const std::function< bool(AudacityProject &) >, nullptr, Options... >::Scope Scope
void UnlinkAccount(AudiocomTrace)
Removes access and refresh token, notifies about the logout.
DialogButtonIdentifier ShowDialog(std::function< DialogButtonIdentifier()> poller={})
ProjectCloudUIExtension(AudacityProject &project)
static ProjectCloudUIExtension & Get(AudacityProject &project)
void OnCloudStatusChanged(const CloudStatusChangedMessage &message)
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
void Yield()
Dispatch waiting events, including actions enqueued by CallAfter.
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
const AttachedProjectObjects::RegisteredFactory key
OnCloseHook::Scope onCloseHookScope
void ReopenProject(AudacityProject &project)
bool ResaveLocally(AudacityProject &project)
void SaveToCloud(AudacityProject &project, UploadMode mode, CreateSnapshotCallback snapshotCallback)
void ResumeProjectUpload(ProjectCloudExtension &projectCloudExtension, std::function< void(AudiocomTrace)> onBeforeUploadStarts)
UserService & GetUserService()
OAuthService & GetOAuthService()
Returns the instance of the OAuthService.
const ServiceConfig & GetServiceConfig()
Returns the instance of the ServiceConfig.
std::string ToUTF8(const std::wstring &wstr)
wxString ToWXString(const std::string &str)
bool IsSyncing() const noexcept
AudiocomTrace audiocomTrace
std::optional< CloudSyncError > Error