Audacity 3.2.0
LocalProjectSnapshot.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 CloudProjectSnapshot.h
7
8 Dmitry Vedenko
9
10**********************************************************************/
11#pragma once
12
13#include <atomic>
14#include <functional>
15#include <future>
16#include <memory>
17#include <mutex>
18#include <string_view>
19
21#include "CloudSyncError.h"
22#include "CloudSyncDTO.h"
23#include "NetworkUtils.h"
24
26
27class AudacityProject;
28enum class AudiocomTrace;
29
31{
32class OAuthService;
33class ServiceConfig;
34} // namespace audacity::cloud::audiocom
35
37{
38constexpr auto UNASSIGNED_PROJECT_ID = -1;
39
42class MixdownUploader;
43class CloudSyncUI;
45
47
48class CLOUD_AUDIOCOM_API LocalProjectSnapshot final :
50 public std::enable_shared_from_this<LocalProjectSnapshot>
51{
52 struct Tag final
53 {
54 };
55
56public:
57 struct CLOUD_AUDIOCOM_API SnapshotData final
58 {
59 std::optional<CreateSnapshotResponse> Response;
60 std::shared_ptr<LocalProjectSnapshot> Operation;
61 };
62
63 using Promise = std::promise<SnapshotData>;
64 using Future = std::future<SnapshotData>;
65
67 Tag, const ServiceConfig& config, const OAuthService& oauthService,
69 AudiocomTrace trace);
70 ~LocalProjectSnapshot() override;
71
72 static Future Create(
73 const ServiceConfig& config, const OAuthService& oauthService,
75 AudiocomTrace trace);
76
77 bool IsCompleted() const override;
78
79 std::shared_ptr<AudacityProject> GetProject();
80
81 void Start() override;
82 void SetUploadData(const ProjectUploadData& data) override;
83 void Cancel() override;
84
85 void Abort();
86
87private:
88 void UploadFailed(CloudSyncError error);
89 void DataUploadFailed(const ResponseResult& uploadResult);
90 void DataUploadFailed(const MissingBlocksUploadProgress& uploadResult);
91
92 void UpdateProjectSnapshot();
93
94 void
95 OnSnapshotCreated(const CreateSnapshotResponse& response, bool newProject);
96 void StorePendingSnapshot(
97 const CreateSnapshotResponse& response, const ProjectUploadData& data);
98 void MarkSnapshotSynced();
99 void DeleteSnapshot();
100
101
103 std::weak_ptr<AudacityProject> mWeakProject;
104
105 std::promise<ProjectUploadData> mProjectDataPromise;
106
110
111 std::string mProjectName;
112
113 struct ProjectBlocksLock;
114 std::unique_ptr<ProjectBlocksLock> mProjectBlocksLock;
115
116 std::shared_ptr<MissingBlocksUploader> mMissingBlockUploader;
117
119 std::optional<CreateSnapshotResponse> mCreateSnapshotResponse;
120
122
124
126
127 std::atomic<bool> mCompleted { false };
128 std::atomic<bool> mCancelled { false };
129 std::atomic<bool> mProjectDataReady { false };
130};
131} // namespace audacity::cloud::audiocom::sync
AudiocomTrace
Definition: ExportUtils.h:27
wxString name
Definition: TagsEditor.cpp:166
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Service responsible for OAuth authentication against the audio.com service.
Definition: OAuthService.h:43
Configuration for the audio.com.
Definition: ServiceConfig.h:25
std::unique_ptr< ProjectBlocksLock > mProjectBlocksLock
std::optional< CreateSnapshotResponse > mCreateSnapshotResponse
std::shared_ptr< MissingBlocksUploader > mMissingBlockUploader
concurrency::CancellationContextPtr mCancellationContext
const AudacityProject & GetProject(const Track &track)
Definition: TrackArt.cpp:479
std::shared_ptr< CancellationContext > CancellationContextPtr