summaryrefslogtreecommitdiffstats
path: root/src/sources
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-03-25 20:33:31 +0100
committerUwe Klotz <uklotz@mixxx.org>2021-04-02 16:15:29 +0200
commit5111af72d8d8e11b69391898d5d089d8a3c5e441 (patch)
treeffac6e2577acae1741a8934ce2f0911f6896c461 /src/sources
parentfb747b6bbf92311b14b93c9500c8fac360cb2eb9 (diff)
Refactor the Sandbox interface for FileInfo/FileAccess
...to pepare for removing TrackFile.
Diffstat (limited to 'src/sources')
-rw-r--r--src/sources/soundsourceproxy.cpp37
-rw-r--r--src/sources/soundsourceproxy.h16
2 files changed, 22 insertions, 31 deletions
diff --git a/src/sources/soundsourceproxy.cpp b/src/sources/soundsourceproxy.cpp
index cc07e1ebe7..a1282a9a96 100644
--- a/src/sources/soundsourceproxy.cpp
+++ b/src/sources/soundsourceproxy.cpp
@@ -251,20 +251,15 @@ bool SoundSourceProxy::registerProviders() {
// static
bool SoundSourceProxy::isUrlSupported(const QUrl& url) {
- return isFileSupported(TrackFile::fromUrl(url));
+ return isFileSupported(mixxx::FileInfo::fromQUrl(url));
}
// static
-bool SoundSourceProxy::isFileSupported(const QFileInfo& fileInfo) {
+bool SoundSourceProxy::isFileSupported(const mixxx::FileInfo& fileInfo) {
return isFileNameSupported(fileInfo.fileName());
}
// static
-bool SoundSourceProxy::isFileSupported(const TrackFile& trackFile) {
- return isFileNameSupported(trackFile.fileName());
-}
-
-// static
bool SoundSourceProxy::isFileNameSupported(const QString& fileName) {
return fileName.contains(getSupportedFileNamesRegex());
}
@@ -309,11 +304,8 @@ SoundSourceProxy::allProviderRegistrationsForUrl(
//static
TrackPointer SoundSourceProxy::importTemporaryTrack(
- TrackFile trackFile,
- SecurityTokenPointer pSecurityToken) {
- TrackPointer pTrack = Track::newTemporary(
- std::move(trackFile),
- std::move(pSecurityToken));
+ mixxx::FileAccess trackFileAccess) {
+ TrackPointer pTrack = Track::newTemporary(std::move(trackFileAccess));
// Lock the track cache while populating the temporary track
// object to ensure that no metadata is exported into any file
// while reading from this file. Since locking individual files
@@ -325,16 +317,13 @@ TrackPointer SoundSourceProxy::importTemporaryTrack(
//static
QImage SoundSourceProxy::importTemporaryCoverImage(
- TrackFile trackFile,
- SecurityTokenPointer pSecurityToken) {
- if (!trackFile.checkFileExists()) {
+ mixxx::FileAccess trackFileAccess) {
+ if (!trackFileAccess.info().checkFileExists()) {
// Silently ignore missing files to avoid spaming the log:
// https://bugs.launchpad.net/mixxx/+bug/1875237
return QImage();
}
- TrackPointer pTrack = Track::newTemporary(
- std::move(trackFile),
- std::move(pSecurityToken));
+ TrackPointer pTrack = Track::newTemporary(std::move(trackFileAccess));
// Lock the track cache while populating the temporary track
// object to ensure that no metadata is exported into any file
// while reading from this file. Since locking individual files
@@ -350,7 +339,7 @@ SoundSourceProxy::exportTrackMetadataBeforeSaving(Track* pTrack, UserSettingsPoi
const auto fileInfo = pTrack->getFileInfo();
mixxx::MetadataSourcePointer pMetadataSource;
{
- auto proxy = SoundSourceProxy(fileInfo.toUrl());
+ auto proxy = SoundSourceProxy(fileInfo.toQUrl());
// Ensure that the actual audio properties of the
// stream are available before exporting metadata.
// This might be needed for converting sample positions
@@ -383,7 +372,7 @@ SoundSourceProxy::SoundSourceProxy(
TrackPointer pTrack,
const mixxx::SoundSourceProviderPointer& pProvider)
: m_pTrack(std::move(pTrack)),
- m_url(m_pTrack ? m_pTrack->getFileInfo().toUrl() : QUrl()),
+ m_url(m_pTrack ? m_pTrack->getFileInfo().toQUrl() : QUrl()),
m_providerRegistrations(allProviderRegistrationsForUrl(m_url)),
m_providerRegistrationIndex(-1) {
initSoundSource(pProvider);
@@ -643,20 +632,20 @@ void SoundSourceProxy::updateTrackFromSource(
// SoundSourceProxy for just a few people.
const bool splitArtistTitle =
trackMetadata.getTrackInfo().getArtist().trimmed().isEmpty();
- const auto trackFile = m_pTrack->getFileInfo();
+ const auto fileInfo = m_pTrack->getFileInfo();
kLogger.info()
<< "Parsing missing"
<< (splitArtistTitle ? "artist/title" : "title")
<< "from file name:"
- << trackFile;
+ << fileInfo;
if (trackMetadata.refTrackInfo().parseArtistTitleFromFileName(
- trackFile.fileName(), splitArtistTitle)) {
+ fileInfo.fileName(), splitArtistTitle)) {
// Pretend that metadata import succeeded
metadataImported.first = mixxx::MetadataSource::ImportResult::Succeeded;
if (metadataImported.second.isNull()) {
// Since this is also some kind of metadata import, we mark the
// track's metadata as synchronized with the time stamp of the file.
- metadataImported.second = trackFile.fileLastModified();
+ metadataImported.second = fileInfo.lastModified();
}
}
}
diff --git a/src/sources/soundsourceproxy.h b/src/sources/soundsourceproxy.h
index 5a149fe6e4..7e42d1ea72 100644
--- a/src/sources/soundsourceproxy.h
+++ b/src/sources/soundsourceproxy.h
@@ -3,9 +3,14 @@
#include "preferences/usersettings.h"
#include "sources/soundsourceproviderregistry.h"
#include "track/track_decl.h"
-#include "track/trackfile.h"
#include "util/sandbox.h"
+namespace mixxx {
+
+class FileAccess;
+
+} // namespace mixxx
+
/// Creates sound sources for tracks. Only intended to be used
/// in a narrow scope and not shareable between multiple threads!
class SoundSourceProxy {
@@ -29,8 +34,7 @@ class SoundSourceProxy {
}
static bool isUrlSupported(const QUrl& url);
- static bool isFileSupported(const TrackFile& trackFile);
- static bool isFileSupported(const QFileInfo& fileInfo);
+ static bool isFileSupported(const mixxx::FileInfo& fileInfo);
static bool isFileNameSupported(const QString& fileName);
static bool isFileExtensionSupported(const QString& fileExtension);
@@ -46,11 +50,9 @@ class SoundSourceProxy {
// The following import functions ensure that the file will not be
// written while reading it!
static TrackPointer importTemporaryTrack(
- TrackFile trackFile,
- SecurityTokenPointer pSecurityToken = SecurityTokenPointer());
+ mixxx::FileAccess trackFileAccess);
static QImage importTemporaryCoverImage(
- TrackFile trackFile,
- SecurityTokenPointer pSecurityToken = SecurityTokenPointer());
+ mixxx::FileAccess trackFileAccess);
explicit SoundSourceProxy(
TrackPointer pTrack,