41 XO(
"Open trace audio.com"),
XO(
"Synchronizing project"),
47 return [&dialog](
double progress)
49 return dialog.
Poll(
static_cast<unsigned>(progress * 10000), 10000ULL) ==
57 while (future.wait_for(std::chrono::milliseconds(50)) !=
58 std::future_status::ready)
74 "Opening of the cloud project was canceled", result.
Result.
Content);
86 wxLogError(
"Failed to open cloud project: %s", result.
Result.
Content);
103 return ConflictResolution::None;
108 const auto resolution = dialog.ShowDialog();
111 return ConflictResolution::Stop;
114 return ConflictResolution::Local;
117 return ConflictResolution::Remote;
120 return ConflictResolution::Stop;
126 "Transfer stats: %f Kb transferred, %f secs",
141 auto iter = std::find_if(
183 auto snapshotIdFuture =
186 auto snapshotIdResult =
GetResult(snapshotIdFuture);
188 if (std::holds_alternative<std::string>(snapshotIdResult))
190 const auto headSnapshotId =
191 *std::get_if<std::string>(&snapshotIdResult);
197 auto dialog = std::make_unique<ProjectVersionConflictDialog>(
200 const auto result = dialog->ShowDialog();
208 newProject, projectId, headSnapshotId,
215 return openedProject;
222 std::string(projectId), std::string(snapshotId), mode,
228 progressDialog.reset();
230 const auto conflictResolution =
233 if (conflictResolution == ConflictResolution::Stop)
236 if (conflictResolution == ConflictResolution::Remote)
239 potentialTarget, projectId, snapshotId,
258 std::string_view snapshotId,
bool forceNew)
261 potentialTarget, projectId, snapshotId,
292 progressDialog.reset();
296 if (conflictResolution == ConflictResolution::Stop)
299 if (conflictResolution == ConflictResolution::Remote)
312 const auto parsedUri =
ParseUri(uri);
314 if (parsedUri.Scheme !=
"audacity" || parsedUri.Host !=
"open")
319 if (queryParameters.empty())
322 const auto projectId = queryParameters.find(
"projectId");
324 if (projectId == queryParameters.end())
327 const auto snapshotId = queryParameters.find(
"snapshotId");
329 const auto forceNew = queryParameters.find(
"new") != queryParameters.end();
333 snapshotId != queryParameters.end() ? snapshotId->second :
344 if (!projectCloudExtension.IsCloudProject())
349 projectId = std::string(projectCloudExtension.GetCloudProjectId())]
351 auto newProject = ProjectManager::New();
352 ProjectWindow::Get(project).Close(true);
353 OpenProjectFromCloud(
354 newProject, projectId, {},
Toolkit-neutral facade for basic user interface services.
#define ASSERT_MAIN_THREAD()
Declare functions to perform UTF-8 to std::wstring conversions.
QueryFields ParseUriQuery(std::string_view query, std::string_view delimiter) noexcept
Parses URI query and returns QueryFields structure with parsed fields.
UriFields ParseUri(std::string_view uri) noexcept
const_iterator end() const
Container::value_type value_type
const_iterator begin() const
const_reverse_iterator rbegin() const
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Abstraction of a progress dialog with well defined time-to-completion estimate.
virtual ProgressResult Poll(unsigned long long numerator, unsigned long long denominator, const TranslatableString &message={})=0
Update the bar and poll for clicks. Call only on the main thread.
static ProjectFileIO & Get(AudacityProject &project)
static AudacityProject * New()
static AudacityProject * OpenProject(AudacityProject *pGivenProject, const FilePath &fileNameArg, bool addtohistory, bool reuseNonemptyProject)
Open a file into an AudacityProject, returning the project, or nullptr for failure.
static ProjectWindow & Get(AudacityProject &project)
GetHeadSnapshotIDFuture GetHeadSnapshotID(std::string_view projectId)
SyncFuture SyncProject(AudacityProject &project, const std::string &path, bool forceSync, sync::ProgressCallback callback)
static CloudSyncService & Get()
SyncFuture OpenFromCloud(std::string projectId, std::string snapshotId, SyncMode mode, sync::ProgressCallback callback)
Open the project from the cloud. This operation is asynchronous.
DialogButtonIdentifier ShowDialog(std::function< DialogButtonIdentifier()> poller={})
static DialogButtonIdentifier CancelButtonIdentifier()
std::string GetSnapshotId() const
std::string GetCloudProjectId() const
static ProjectCloudExtension & Get(AudacityProject &project)
static DialogButtonIdentifier UseRemoteIdentifier()
static DialogButtonIdentifier UseLocalIdentifier()
static void OnOpen(const CloudSyncError &error)
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
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.
auto MakePoller(BasicUI::ProgressDialog &dialog)
ConflictResolution GetConfilctResolution(AudacityProject *project, const ProjectSyncResult &result)
bool HandleFailure(const ProjectSyncResult &result)
void LogTransferStats(TransferStats stats)
T GetResult(std::future< T > &future)
void ReopenProject(AudacityProject &project)
bool HandleProjectLink(std::string_view uri)
bool SyncCloudProject(AudacityProject &project, std::string_view path, AudiocomTrace trace, bool force)
AudacityProject * OpenProjectFromCloud(AudacityProject *potentialTarget, std::string_view projectId, std::string_view snapshotId, CloudSyncService::SyncMode mode)
AudacityProject * GetOpenedProject(std::string_view projectId)
AudacityProject * GetPotentialTarget()
AuthResult PerformBlockingAuth(AudacityProject *project, AudiocomTrace trace, const TranslatableString &alternativeActionLabel)
wxString ToWXString(const std::string &str)
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept
Duration TransferDuration