61 projectCloudExtenstion.OnLoad();
63 if (projectCloudExtenstion.IsCloudProject())
77 projectCloudExtension.OnSyncStarted();
79 auto future = LocalProjectSnapshot::Create(
83 mUploadMode = UploadMode::Normal;
90 auto result = future.get();
100 result.Operation->Abort();
102 projectCloudExtension.OnSyncCompleted(
108 if (mSnapshotCallback)
110 mSnapshotCallback(*result.Response);
111 mSnapshotCallback = {};
123 if (authResult.Result == AuthResult::Status::Failure)
134 else if (authResult.Result == AuthResult::Status::UseAlternative)
140 return PerformCloudSave(
143 projectSaveCallback,
false, trace);
153 const bool isTemporary = projectFileIO.IsTemporary();
154 const bool isCloudProject = projectCloudExtension.IsCloudProject();
156 const bool forceSaveToCloud =
166 if (isTemporary && !forceSaveToCloud)
169 LocationDialogType::Save };
170 const auto saveAction = cloudLocationDialog.
ShowDialog();
173 if (saveAction == LocationDialogResult::Local)
175 else if (saveAction == LocationDialogResult::Cancel)
180 if (!isTemporary && !forceSaveToCloud && !isCloudProject)
183 const auto trace = forceSaveToCloud ?
188 return SaveCloudProject(
project, projectSaveCallback, trace);
192 project.GetProjectName(), parent,
false, trace);
194 if (result.first == CloudProjectPropertiesDialog::Action::Cancel)
198 result.first == CloudProjectPropertiesDialog::Action::SaveLocally)
207 return PerformCloudSave(
209 projectSaveCallback,
true, mAudiocomTrace);
216 if (!projectCloudExtension.IsCloudProject())
228 if (!projectCloudExtension.IsCloudProject())
231 projectCloudExtension.OnUpdateSaved(serializer);
233 const int savesCount = projectCloudExtension.GetSavesCount();
240 if (projectCloudExtension.IsFirstSyncDialogShown())
244 [weakProject =
project.weak_from_this()] {
245 auto project = weakProject.lock();
250 return ProjectCloudExtension::Get(*project)
251 .GetCurrentSyncStatus() == ProjectSyncStatus::Synced;
253 [weakProject =
project.weak_from_this(), trace = mAudiocomTrace] {
254 auto project = weakProject.lock();
258 ProjectCloudExtension::Get(*project).IsFirstSyncDialogShown())
261 ProjectCloudExtension::Get(*project).SetFirstSyncDialogShown(true);
264 SyncSucceededDialog { project.get() }.ShowDialog();
266 if (result == SyncSucceededDialog::ViewOnlineIdentifier())
292 mSnapshotCallback = std::move(callback);
325 ioExtension.ForceCloudSave();
326 ioExtension.SetUploadModeForNextSave(mode);
327 ioExtension.SetSnapshotCallbackForNextSave(std::move(snapshotCallback));
Toolkit-neutral facade for basic user interface services.
#define ASSERT_MAIN_THREAD()
Declare functions to perform UTF-8 to std::wstring conversions.
@ SaveProjectSaveToCloudMenu
std::function< bool(const std::string &path, bool nameChanged)> ProjectSaveCallback
OnOpenAction
Action the ProjectManager should take after the open hooks were called.
@ Continue
ProjectManager should continue with the open.
@ Cancel
Open was cancelled by the extension.
OnSaveAction
Action the ProjectManager should take after the save hooks were called.
@ Handled
Save was handled by the extension.
@ Continue
Save was not handled by the extension.
@ Cancelled
Save was cancelled by the extension.
OnCloseAction
Action the ProjectManager should take after the close hooks were called.
@ Veto
Extension vetoed the close.
@ Continue
Extension did not veto the close.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Set of hooks for project file I/O.
static ProjectFileIO & Get(AudacityProject &project)
const FilePath & GetFileName() const
bool SaveAs(bool allowOverwrite=false)
static ProjectFileManager & Get(AudacityProject &project)
a class used to (de)serialize the project catalog
static ProjectWindow & Get(AudacityProject &project)
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
void SetUploadModeForNextSave(UploadMode mode)
OnSaveAction PerformCloudSave(AudacityProject &project, std::string name, std::string filePath, const ProjectSaveCallback &projectSaveCallback, bool fileRenamed, AudiocomTrace trace)
OnSaveAction OnSave(AudacityProject &project, const ProjectSaveCallback &projectSaveCallback) override
This hook is called before the project is saved.
OnSaveAction SaveCloudProject(AudacityProject &project, const ProjectSaveCallback &projectSaveCallback, AudiocomTrace trace)
bool IsBlockLocked(const AudacityProject &project, int64_t blockId) const override
This hook is called to check if a block is locked.
OnCloseAction OnClose(AudacityProject &project) override
This hook is called before the project is closed.
void SetSnapshotCallbackForNextSave(CreateSnapshotCallback callback)
void OnLoad(AudacityProject &project) override
This hook is called after the project is loaded.
OnOpenAction OnOpen(AudacityProject &project, const std::string &path) override
This hook is called before the project is opened.
void OnUpdateSaved(AudacityProject &project, const ProjectSerializer &serializer) override
This hook is called after the project blob is saved.
CreateSnapshotCallback mSnapshotCallback
LocationDialogResult ShowDialog()
static ProjectCloudExtension & Get(AudacityProject &project)
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)
FILES_API wxString MkDir(const wxString &Str)
ProjectFileIOExtensionRegistry::Extension extension
IOExtension & GetExtension()
bool ResaveLocally(AudacityProject &project)
void SaveToCloud(AudacityProject &project, UploadMode mode, CreateSnapshotCallback snapshotCallback)
bool SyncCloudProject(AudacityProject &project, std::string_view path, AudiocomTrace trace, bool force)
wxString MakeSafeProjectPath(const wxString &rootDir, const wxString &projectName)
void ResumeProjectUpload(ProjectCloudExtension &projectCloudExtension, std::function< void(AudiocomTrace)> onBeforeUploadStarts)
std::function< void(const CreateSnapshotResponse &)> CreateSnapshotCallback
void ShowDialogOn(std::function< bool()> condition, std::function< void()> dialogFactory)
StringSetting CloudProjectsSavePath
AuthResult PerformBlockingAuth(AudacityProject *project, AudiocomTrace trace, const TranslatableString &alternativeActionLabel)
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)
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...