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

#include <ProjectCloudUIExtension.h>

Inheritance diagram for audacity::cloud::audiocom::sync::ProjectCloudUIExtension:
[legend]
Collaboration diagram for audacity::cloud::audiocom::sync::ProjectCloudUIExtension:
[legend]

Public Member Functions

 ProjectCloudUIExtension (AudacityProject &project)
 
 ~ProjectCloudUIExtension () override
 
bool AllowClosing ()
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Static Public Member Functions

static ProjectCloudUIExtensionGet (AudacityProject &project)
 
static const ProjectCloudUIExtensionGet (const AudacityProject &project)
 

Private Member Functions

void SetUploadProgress (double progress)
 
void OnCloudStatusChanged (const CloudStatusChangedMessage &message)
 

Private Attributes

AudacityProjectmProject
 
std::unique_ptr< BasicUI::ProgressDialogmProgressDialog
 
double mProgress { 0.0 }
 
std::atomic< bool > mInSync { false }
 
bool mClosingCancelled { false }
 
Observer::Subscription mCloudStatusChangedSubscription
 

Detailed Description

Definition at line 29 of file ProjectCloudUIExtension.h.

Constructor & Destructor Documentation

◆ ProjectCloudUIExtension()

audacity::cloud::audiocom::sync::ProjectCloudUIExtension::ProjectCloudUIExtension ( AudacityProject project)
explicit

Definition at line 50 of file ProjectCloudUIExtension.cpp.

51 : mProject { project }
54 [this](const auto& status) { OnCloudStatusChanged(status); }, true)
55 }
56{
57}
const auto project
static ProjectCloudExtension & Get(AudacityProject &project)
Observer::Subscription SubscribeStatusChanged(std::function< void(const CloudStatusChangedMessage &)> callback, bool onUIThread)
void OnCloudStatusChanged(const CloudStatusChangedMessage &message)

References OnCloudStatusChanged().

Here is the call graph for this function:

◆ ~ProjectCloudUIExtension()

audacity::cloud::audiocom::sync::ProjectCloudUIExtension::~ProjectCloudUIExtension ( )
overridedefault

Member Function Documentation

◆ AllowClosing()

bool audacity::cloud::audiocom::sync::ProjectCloudUIExtension::AllowClosing ( )

Definition at line 77 of file ProjectCloudUIExtension.cpp.

78{
79 while (mInSync.load(std::memory_order_acquire) && !mClosingCancelled)
80 {
81 if (mProgressDialog == nullptr)
82 {
84 XO("Save to audio.com"),
85 XO("Project is syncing with audio.com. Do you want to stop the sync process?"),
87 }
88
89 const auto result = mProgressDialog->Poll(mProgress * 10000, 10000);
90
92 {
93 mClosingCancelled = true;
94 mProgressDialog.reset();
95 }
96
99
101 }
102
103 bool closingCancelled = mClosingCancelled;
104 mClosingCancelled = false;
105
106 mProgressDialog.reset();
107
108 return !mInSync.load(std::memory_order_acquire) || !closingCancelled;
109}
XO("Cut/Copy/Paste")
std::unique_ptr< BasicUI::ProgressDialog > mProgressDialog
@ ProgressShowCancel
Definition: BasicUI.h:142
@ ProgressShowStop
Definition: BasicUI.h:141
void Yield()
Dispatch waiting events, including actions enqueued by CallAfter.
Definition: BasicUI.cpp:225
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Definition: BasicUI.h:302

References BasicUI::Cancelled, BasicUI::Get(), BasicUI::MakeProgress(), BasicUI::ProgressShowCancel, BasicUI::ProgressShowStop, BasicUI::Stopped, XO(), and BasicUI::Yield().

Here is the call graph for this function:

◆ Get() [1/2]

ProjectCloudUIExtension & audacity::cloud::audiocom::sync::ProjectCloudUIExtension::Get ( AudacityProject project)
static

◆ Get() [2/2]

const ProjectCloudUIExtension & audacity::cloud::audiocom::sync::ProjectCloudUIExtension::Get ( const AudacityProject project)
static

Definition at line 67 of file ProjectCloudUIExtension.cpp.

68{
69 return Get(const_cast<AudacityProject&>(project));
70}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static ProjectCloudUIExtension & Get(AudacityProject &project)

References project.

◆ OnCloudStatusChanged()

void audacity::cloud::audiocom::sync::ProjectCloudUIExtension::OnCloudStatusChanged ( const CloudStatusChangedMessage message)
private

Definition at line 111 of file ProjectCloudUIExtension.cpp.

113{
114 mInSync = message.IsSyncing();
115
116 if (!mInSync)
117 mProgressDialog.reset();
118 else
119 SetUploadProgress(message.Progress);
120
121 // It the sync was successful - check for unsuccessful operations before
122 if (message.Status == ProjectSyncStatus::Synced)
124
125 if (message.Status != ProjectSyncStatus::Failed || !message.Error)
126 return;
127
128 const auto error = *message.Error;
129
130 switch (error.Type)
131 {
133 // How do we got here? Probable auth_token is invalid?
134 GetOAuthService().UnlinkAccount(message.audiocomTrace);
136 break;
138 [[fallthrough]];
140 {
141 auto result = ProjectLimitDialog { &mProject }.ShowDialog();
142
144 {
145 const auto slug = audacity::ToUTF8(GetUserService().GetUserSlug());
146
148 GetServiceConfig().GetProjectsPageUrl(slug, message.audiocomTrace));
149
150 WaitForActionDialog {
151 &mProject,
152 XO("Waiting for space to free up"),
153 XO("Once you have made storage space available on audio.com, click Retry."),
154 }
155 .ShowDialog();
157 }
159 {
162 }
163 }
164 break;
166 {
167 if (
168 ProjectVersionConflictDialog { &mProject,
171 {
173 }
174 else
175 {
177 }
178 }
179 break;
181 {
182 if (
183 NotCloudProjectDialog { &mProject }.ShowDialog() ==
185 {
188 }
189 else
190 {
192 }
193 }
194 break;
196 {
197 ConnectionIssuesDialog { &mProject }.ShowDialog();
198 }
199 break;
201 [[fallthrough]];
203 [[fallthrough]];
206 break;
208 [[fallthrough]];
209 default:
210 break;
211 }
212
213 wxLogError(
214 "Cloud sync has failed: %s", audacity::ToWXString(error.ErrorMessage));
215}
void UnlinkAccount(AudiocomTrace)
Removes access and refresh token, notifies about the logout.
static DialogButtonIdentifier SaveLocallyButtonIdentifier()
static void OnSave(const CloudSyncError &error)
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
Definition: BasicUI.cpp:246
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)

References audacity::cloud::audiocom::sync::CloudStatusChangedMessage::audiocomTrace, audacity::network_manager::common_headers::Authorization, RefreshCode::Cancelled, audacity::cloud::audiocom::sync::CloudStatusChangedMessage::Error, BasicUI::Get(), audacity::cloud::audiocom::GetOAuthService(), audacity::cloud::audiocom::GetServiceConfig(), audacity::cloud::audiocom::GetUserService(), audacity::cloud::audiocom::sync::CloudStatusChangedMessage::IsSyncing(), anonymous_namespace{FileMenus.cpp}::OnSave(), BasicUI::OpenInDefaultBrowser(), audacity::cloud::audiocom::sync::CloudStatusChangedMessage::Progress, audacity::cloud::audiocom::sync::ReopenProject(), audacity::cloud::audiocom::sync::ResaveLocally(), audacity::cloud::audiocom::sync::ResumeProjectUpload(), audacity::cloud::audiocom::sync::SaveToCloud(), audacity::cloud::audiocom::sync::AudioComDialogBase::ShowDialog(), audacity::cloud::audiocom::sync::CloudStatusChangedMessage::Status, audacity::ToUTF8(), audacity::ToWXString(), audacity::cloud::audiocom::OAuthService::UnlinkAccount(), and XO().

Referenced by ProjectCloudUIExtension().

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

◆ SetUploadProgress()

void audacity::cloud::audiocom::sync::ProjectCloudUIExtension::SetUploadProgress ( double  progress)
private

Definition at line 72 of file ProjectCloudUIExtension.cpp.

73{
74 mProgress = progress;
75}

Member Data Documentation

◆ mClosingCancelled

bool audacity::cloud::audiocom::sync::ProjectCloudUIExtension::mClosingCancelled { false }
private

Definition at line 51 of file ProjectCloudUIExtension.h.

◆ mCloudStatusChangedSubscription

Observer::Subscription audacity::cloud::audiocom::sync::ProjectCloudUIExtension::mCloudStatusChangedSubscription
private

Definition at line 53 of file ProjectCloudUIExtension.h.

◆ mInSync

std::atomic<bool> audacity::cloud::audiocom::sync::ProjectCloudUIExtension::mInSync { false }
private

Definition at line 50 of file ProjectCloudUIExtension.h.

◆ mProgress

double audacity::cloud::audiocom::sync::ProjectCloudUIExtension::mProgress { 0.0 }
private

Definition at line 48 of file ProjectCloudUIExtension.h.

◆ mProgressDialog

std::unique_ptr<BasicUI::ProgressDialog> audacity::cloud::audiocom::sync::ProjectCloudUIExtension::mProgressDialog
private

Definition at line 46 of file ProjectCloudUIExtension.h.

◆ mProject

AudacityProject& audacity::cloud::audiocom::sync::ProjectCloudUIExtension::mProject
private

Definition at line 44 of file ProjectCloudUIExtension.h.


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