Audacity 3.2.0
Classes | Functions | Variables
cloud::audiocom::anonymous_namespace{UploadService.cpp} Namespace Reference

Classes

struct  AudiocomUploadOperation
 

Functions

std::string_view DeduceMimeType (const wxString &ext)
 
std::string GetUploadRequestPayload (const wxString &filePath, const wxString &projectName, bool isPublic)
 
std::string GetProgressPayload (uint64_t current, uint64_t total)
 

Variables

const auto tempChangedSubscription
 

Function Documentation

◆ DeduceMimeType()

std::string_view cloud::audiocom::anonymous_namespace{UploadService.cpp}::DeduceMimeType ( const wxString &  ext)

Definition at line 41 of file UploadService.cpp.

42{
43 if (ext == "wv")
44 return "audio/x-wavpack";
45 else if (ext == "flac")
46 return "audio/x-flac";
47 else if (ext == "mp3")
48 return "audio/mpeg";
49 else
50 return "audio/x-wav";
51}

Referenced by GetUploadRequestPayload(), and cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::HandleUploadPolicy().

Here is the caller graph for this function:

◆ GetProgressPayload()

std::string cloud::audiocom::anonymous_namespace{UploadService.cpp}::GetProgressPayload ( uint64_t  current,
uint64_t  total 
)

Definition at line 102 of file UploadService.cpp.

103{
104 rapidjson::Document document;
105 document.SetObject();
106
107 document.AddMember(
108 "progress", rapidjson::Value(current / static_cast<double>(total) * 100.0),
109 document.GetAllocator());
110
111 rapidjson::StringBuffer buffer;
112 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
113 document.Accept(writer);
114
115 return std::string(buffer.GetString());
116}

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::HandleUploadProgress().

Here is the caller graph for this function:

◆ GetUploadRequestPayload()

std::string cloud::audiocom::anonymous_namespace{UploadService.cpp}::GetUploadRequestPayload ( const wxString &  filePath,
const wxString &  projectName,
bool  isPublic 
)

Definition at line 53 of file UploadService.cpp.

55{
56 rapidjson::Document document;
57 document.SetObject();
58
59 const wxFileName fileName(filePath);
60 const auto mimeType = DeduceMimeType(fileName.GetExt());
61
62 document.AddMember(
63 "mime",
64 rapidjson::Value(
65 mimeType.data(), mimeType.length(), document.GetAllocator()),
66 document.GetAllocator());
67
68 const auto downloadMime = GetServiceConfig().GetDownloadMime();
69
70 if (!downloadMime.empty())
71 {
72 document.AddMember(
73 "download_mime",
74 rapidjson::Value(
75 downloadMime.data(), downloadMime.length(),
76 document.GetAllocator()),
77 document.GetAllocator());
78 }
79
80 const auto name = audacity::ToUTF8(projectName.empty() ? fileName.GetFullName() : projectName);
81
82 document.AddMember(
83 "name",
84 rapidjson::Value(name.data(), name.length(), document.GetAllocator()),
85 document.GetAllocator());
86
87 document.AddMember(
88 "size",
89 rapidjson::Value(static_cast<int64_t>(fileName.GetSize().GetValue())),
90 document.GetAllocator());
91
92 document.AddMember(
93 "public", rapidjson::Value(isPublic), document.GetAllocator());
94
95 rapidjson::StringBuffer buffer;
96 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
97 document.Accept(writer);
98
99 return std::string(buffer.GetString());
100}
const TranslatableString name
Definition: Distortion.cpp:76
MimeType GetDownloadMime() const
Return the mime type server should store the file. This is a requirement from audiocom.
std::string ToUTF8(const std::wstring &wstr)
std::string_view DeduceMimeType(const wxString &ext)
const ServiceConfig & GetServiceConfig()
Returns the instance of the ServiceConfig.

References DeduceMimeType(), cloud::audiocom::ServiceConfig::GetDownloadMime(), cloud::audiocom::GetServiceConfig(), name, and audacity::ToUTF8().

Referenced by cloud::audiocom::anonymous_namespace{UploadService.cpp}::AudiocomUploadOperation::InitiateUpload().

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

Variable Documentation

◆ tempChangedSubscription

const auto cloud::audiocom::anonymous_namespace{UploadService.cpp}::tempChangedSubscription
Initial value:
const auto tempPath = GetUploadTempPath();
if (!wxDirExists(tempPath))
return;
wxArrayString files;
wxDir::GetAllFiles(tempPath, &files, {}, wxDIR_FILES);
for (const auto& file : files)
wxRemoveFile(file);
return;
})
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
FILES_API Observer::Publisher< FilePath > & GetTempPathObserver()
wxString GetUploadTempPath()

Definition at line 578 of file UploadService.cpp.