58 projectCloudExtenstion.OnLoad();
60 if (projectCloudExtenstion.IsCloudProject())
62 projectCloudExtenstion,
72 projectCloudExtension.OnSyncStarted();
74 auto future = LocalProjectSnapshot::Create(
78 mUploadMode = UploadMode::Normal;
85 auto result = future.get();
95 result.Operation->Abort();
97 projectCloudExtension.OnSyncCompleted(
103 if (mSnapshotCallback)
105 mSnapshotCallback(*result.Response);
106 mSnapshotCallback = {};
117 if (authResult.Result == AuthResult::Status::Failure)
128 else if (authResult.Result == AuthResult::Status::UseAlternative)
134 return PerformCloudSave(
137 projectSaveCallback,
false);
147 const bool isTemporary = projectFileIO.IsTemporary();
148 const bool isCloudProject = projectCloudExtension.IsCloudProject();
150 const bool pendingCloudSave = mForceCloudSave;
151 mForceCloudSave =
false;
156 if (isTemporary && !pendingCloudSave)
159 LocationDialogType::Save };
160 const auto saveAction = cloudLocationDialog.
ShowDialog();
163 if (saveAction == LocationDialogResult::Local)
165 else if (saveAction == LocationDialogResult::Cancel)
170 if (!isTemporary && !pendingCloudSave && !isCloudProject)
174 return SaveCloudProject(
project, projectSaveCallback);
178 project.GetProjectName(), parent,
false);
180 if (result.first == CloudProjectPropertiesDialog::Action::Cancel)
184 result.first == CloudProjectPropertiesDialog::Action::SaveLocally)
193 return PerformCloudSave(
195 projectSaveCallback,
true);
202 if (!projectCloudExtension.IsCloudProject())
214 if (!projectCloudExtension.IsCloudProject())
217 projectCloudExtension.OnUpdateSaved(serializer);
219 const int savesCount = projectCloudExtension.GetSavesCount();
226 if (projectCloudExtension.IsFirstSyncDialogShown())
230 [weakProject =
project.weak_from_this()]
232 auto project = weakProject.lock();
237 return ProjectCloudExtension::Get(*project)
238 .GetCurrentSyncStatus() == ProjectSyncStatus::Synced;
240 [weakProject =
project.weak_from_this()]
242 auto project = weakProject.lock();
246 ProjectCloudExtension::Get(*project).IsFirstSyncDialogShown())
249 ProjectCloudExtension::Get(*project).SetFirstSyncDialogShown(true);
252 SyncSucceededDialog { project.get() }.ShowDialog();
254 if (result == SyncSucceededDialog::ViewOnlineIdentifier())
269 mForceCloudSave =
true;
279 mSnapshotCallback = std::move(callback);
288 bool mForceCloudSave {};
312 ioExtension.ForceCloudSave();
313 ioExtension.SetUploadModeForNextSave(mode);
314 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.
const TranslatableString name
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 */
OnSaveAction PerformCloudSave(AudacityProject &project, std::string name, std::string filePath, const ProjectSaveCallback &projectSaveCallback, bool fileRenamed)
void SetUploadModeForNextSave(UploadMode mode)
OnSaveAction SaveCloudProject(AudacityProject &project, const ProjectSaveCallback &projectSaveCallback)
OnSaveAction OnSave(AudacityProject &project, const ProjectSaveCallback &projectSaveCallback) override
This hook is called before the project is saved.
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 SyncCloudProject(AudacityProject &project, std::string_view path, bool force)
bool ResaveLocally(AudacityProject &project)
void SaveToCloud(AudacityProject &project, UploadMode mode, CreateSnapshotCallback snapshotCallback)
void ResumeProjectUpload(ProjectCloudExtension &projectCloudExtension, std::function< void()> onBeforeUploadStarts)
wxString MakeSafeProjectPath(const wxString &rootDir, const wxString &projectName)
std::function< void(const CreateSnapshotResponse &)> CreateSnapshotCallback
void ShowDialogOn(std::function< bool()> condition, std::function< void()> dialogFactory)
StringSetting CloudProjectsSavePath
UserService & GetUserService()
OAuthService & GetOAuthService()
Returns the instance of the OAuthService.
AuthResult PerformBlockingAuth(AudacityProject *project, const TranslatableString &alternativeActionLabel)
const ServiceConfig & GetServiceConfig()
Returns the instance of the ServiceConfig.
std::string ToUTF8(const std::wstring &wstr)
wxString ToWXString(const std::string &str)